package TCP.test1;

import java.io.*;
import java.net.Socket;

/*
创建客户端：发送数据，接收服务器反馈
 */
public class ClientDemo {
    public static void main(String[] args) throws IOException {
        Socket s = new Socket("192.168.146.1", 10001);

        //键盘录入
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        //封装输出流对象
        //OutputStream getOutputStream () 返回此套接字的输出流
//        OutputStream os = ds.getOutputStream();
//        os.write("hello,tcp".getBytes());
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(s.getOutputStream()));//将字节输出流封装成字符流数据

        String line;
        while ((line = br.readLine()) != null) {
            if ("886".equals(br)) {
                break;
            } else {
                //获取输出流数据
//                OutputStream os = ds.getOutputStream();
//                os.write(line.getBytes());
                bw.write(line);
                bw.newLine();
                bw.flush();
            }
            s.close();
        }
    }
}
